package com.skd.druid.core;

import com.haulmont.cuba.core.sys.servlet.ServletRegistrationManager;
import com.haulmont.cuba.core.sys.servlet.events.ServletContextInitializedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.servlet.*;

/**
 * Created by green on 2019/7/6.
 */
@Component
public class ServletInitializer {
    public ServletInitializer(){
    }
    @Inject
    private ServletRegistrationManager servletRegistrationManager;

    @EventListener
    public void initializeHttpServlet(ServletContextInitializedEvent e) {

        Servlet servlet = servletRegistrationManager.createServlet(
                e.getApplicationContext(), CUBAStatViewServlet.class.getName());
        ServletRegistration.Dynamic servletRegistration = e.getSource().addServlet(CUBAStatViewServlet.NAME, servlet);
        servletRegistration.addMapping("/druid/*");


    }

}
